package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldLeaveDto;
import com.cleaningcloud.cld.domain.vo.CldLeaveVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldLeave;
import com.cleaningcloud.cld.service.ICldLeaveService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 请假管理Controller
 * 
 * @author cleaningcloud
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/CldLeave")
public class CldLeaveController extends BaseController
{
    @Autowired
    private ICldLeaveService cldLeaveService;

    /**
     * 查询请假管理列表
     */
    @RequiresPermissions("cld:CldLeave:list")
    @GetMapping("/list")
    public TableDataInfo list(CldLeaveDto cldLeave)
    {
        startPage();
        List<CldLeaveVo> list = cldLeaveService.selectCldLeaveList(cldLeave);
        return getDataTable(list);
    }


    /**
     * 获取请假管理详细信息
     */
    @RequiresPermissions("cld:CldLeave:query")
    @GetMapping(value = "/{leaveId}")
    public AjaxResult getInfo(@PathVariable("leaveId") Long leaveId)
    {
        return success(cldLeaveService.selectCldLeaveByLeaveId(leaveId));
    }

    /**
     * 新增请假管理
     */
    @RequiresPermissions("cld:CldLeave:add")
    @Log(title = "请假管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldLeaveDto cldLeave)
    {
        return toAjax(cldLeaveService.insertCldLeave(cldLeave));
    }

    /**
     * 修改请假管理
     */
    @RequiresPermissions("cld:CldLeave:edit")
    @Log(title = "请假管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldLeave cldLeave)
    {
        return toAjax(cldLeaveService.updateCldLeave(cldLeave));
    }



    /**
     * 修改请假管理 - 审核
     */
    @RequiresPermissions("cld:CldLeave:audit")
    @Log(title = "请假管理", businessType = BusinessType.UPDATE)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody CldLeave cldLeave)
    {
        return toAjax(cldLeaveService.auditCldLeave(cldLeave));
    }

    /**
     * 删除请假管理
     */
    @RequiresPermissions("cld:CldLeave:remove")
    @Log(title = "请假管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{leaveIds}")
    public AjaxResult remove(@PathVariable Long[] leaveIds)
    {
        return toAjax(cldLeaveService.deleteCldLeaveByLeaveIds(leaveIds));
    }
}
